package cn.sccl.dirms.topo.discovery.model;

import cn.sccl.dirms.topo.snmp.util.SNMPConfig;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by julei on 2017/9/13.
 */
public class NetScan {

    private String mapName;
    private List<IpRange> ipRangeList;
    private DiscoveryConfig discoveryConfig;
    private List<SNMPConfig> snmpConfigList;

    public NetScan(Map<String, Object> form) {
        Map mapInfo = (Map) form.get("mapInfo");
        if (mapInfo != null && mapInfo.get("name") != null) {
            this.mapName = mapInfo.get("name").toString();
        }
        List<Map> ipList = (List) form.get("ipList");
        this.ipRangeList = new ArrayList<IpRange>();
        if (ipList != null) {
            for (Map ip : ipList) {
                String startIp = ip.get("startIp").toString();
                String endIp = ip.get("endIp").toString();
                IpRange range = new IpRange(startIp, endIp);
                this.ipRangeList.add(range);
            }
        }
        List<Map> snmpConfig = (List) form.get("snmpConfig");
        this.snmpConfigList = new ArrayList<SNMPConfig>();
        if (snmpConfig != null) {
            for (Map snmp : snmpConfig) {
                String community = snmp.get("community").toString();
                int version = Integer.valueOf(snmp.get("version").toString());
                SNMPConfig config = new SNMPConfig(version, community, 161);
                this.snmpConfigList.add(config);
            }
        }
        this.discoveryConfig = new DiscoveryConfig();
        if (mapInfo != null && mapInfo.get("isUsePing") != null) {

        }
    }


    public DiscoveryConfig getDiscoveryConfig() {
        return discoveryConfig;
    }

    public void setDiscoveryConfig(DiscoveryConfig discoveryConfig) {
        this.discoveryConfig = discoveryConfig;
    }

    public String getMapName() {
        return mapName;
    }

    public void setMapName(String mapName) {
        this.mapName = mapName;
    }

    public List<IpRange> getIpRangeList() {
        return ipRangeList;
    }

    public void setIpRangeList(List<IpRange> ipRangeList) {
        this.ipRangeList = ipRangeList;
    }


    public List<SNMPConfig> getSnmpConfigList() {
        return snmpConfigList;
    }

    public void setSnmpConfigList(List<SNMPConfig> snmpConfigList) {
        this.snmpConfigList = snmpConfigList;
    }
}
